<template>
	<view>
		<uni-list><uni-list-item v-for="(value, key, index) in codedata" :key="index" :title="key" :note="value + ''"></uni-list-item></uni-list>
		
		<button type="default" @click="saoma1">允许从相机和相册扫码</button>
		<button type="default" @click="saoma2">允许从相机和相册扫码</button>
		<button type="default" @click="saoma3">允许从相机和相册扫码</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				codedata: {}
			}
		},
		methods: {
			saoma1() {
				let _this = this;
				uni.scanCode({
					success: function(res) {
						_this.codedata = res;
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
			},
			saoma2() {
				let _this = this;
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						_this.codedata = res;
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
			},
			saoma3() {
				let _this = this;
				uni.scanCode({
					scanType: ['barCode'],
					success: function(res) {
						_this.codedata = res;
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					}
				});
			}
		}
	}
</script>

<style scoped>

</style>
